package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import com.fr.report.script.core.FunctionHelper;

public class EXP extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 1)
      return Primitive.ERROR_NAME;
    Object localObject = paramArrayOfObject[0];
    if (localObject instanceof Number)
      return FunctionHelper.parsePrimitiveDouble(Math.exp(((Number)localObject).doubleValue()));
    return Primitive.ERROR_NAME;
  }

  public Function.Type getType()
  {
    return Function.MATH;
  }

  public String getCN()
  {
    return "EXP(number): 返回e的n次幂。常数e为自然对数的底数，等于2.71828182845904。\nNumber:为任意实数，作为常数e的指数。\n备注:\n    如果要返回其他常数作为底数的幂，可以使用指数运算符（^）。例如: 在4^2中，4是底数，而2是指数。\n    EXP函数与LN函数互为反函数。\n示例:\nEXP(0)等于1。\nEXP(3)等于20.08553692。\nEXP(LN(2))等于2。";
  }

  public String getEN()
  {
    return "EXP(number): Returns e raised to the power of number. The constant e equals 2.71828182845904, the base of the natural logarithm.\nNumber is the exponent applied to the base e.\n\nRemarks:\n1. To calculate powers of other bases, use the exponentiation operator (^). For example, in formula 4^2, 4 is base, 2 is exponential.\n2. EXP is the inverse of LN, the natural logarithm of number. \n\nExample:\n   EXP(0)=1\n   EXP(3)=20.08553692\n   EXP(LN(2))=2";
  }
}